<template>
<div class="product-add">
    <!--form表单-->
    <el-form size="small" ref="form" :model="form" label-width="250px">
      <!--小程序设置-->
      <div class="common-form">{{$t('appsetting.miniapp_settings')}}</div>
      <el-form-item :label="$t('appsetting.miniapp_appid')">
        <el-input v-model="form.wxappId" class="max-w460"></el-input>
      </el-form-item>
      <el-form-item :label="$t('appsetting.miniapp_secret')">
        <el-input v-model="form.wxappSecret" class="max-w460"></el-input>
      </el-form-item>
      <div class="common-form">{{$t('appsetting.hkpay_set_up')}}</div>
      <el-form-item :label="$t('appsetting.merchant_id')">
        <el-input v-model="form.wxappMchid" class="max-w460"></el-input>
      </el-form-item>
      <el-form-item :label="$t('appsetting.merchant_signature')">
        <el-input v-model="form.wxappMchkey" class="max-w460"></el-input>
      </el-form-item>

      <!--提交-->
      <div class="common-button-wrapper">
        <el-button type="primary" @click="onSubmit">{{$t('appsetting.submit')}}</el-button>
      </div>
    </el-form>
  </div>
</template>

<script>
import AppSettingApi from "@/api/appsetting.js";
export default {
  data() {
    return {
      /*切换菜单*/
      // activeIndex: '1',
      /*form表单数据*/
      form: {}
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      let self = this;
      AppSettingApi.appwxDetail({}, true).then(res => {
        if (res.data != null) {
          self.form = res.data;
        }
      }).catch(error => {});
    },
    //提交表单
    onSubmit() {
      let self = this;
      let params = this.form;
      AppSettingApi.editAppWx(params, true).then(data => {
        ElMessage({
          message: $t("appsetting.setup_success"),
          type: "success"
        });
        self.$router.push("/appsetting/appwx/index");
      }).catch(error => {});
    }
  }
};
</script>

<style scoped>
.tips {
  color: #ccc;
}
</style>

